<template>
    <NuxtLayout name="default">
        <div class="flex flex-1 overflow-hidden">
            <doc-sidebar ref="docSidebarRef" />

            <NuxtPage
                @upload-success="uploadSuccess"
            />
        </div>
    </NuxtLayout>
</template>

<script setup lang="ts">
import { useRoute } from 'vue-router'
import docSidebar from './_components/doc-sidebar.vue'

const route = useRoute()
const router = useRouter()
const docSidebarRef = shallowRef()

/**
 * 上传成功通知
 *
 * @param code
 * @author zero
 */
const uploadSuccess = (code: string) => {
    docSidebarRef.value?.resetSidebar()
    router.push({
        path: '/apply/docs/chatting',
        query: { code }
    })
}

onMounted(() => {
    if (route.path === '/apply/docs') {
        router.push({
            path: '/apply/docs/uploader'
        })
    }
})
</script>
